#pragma once

#ifndef CORE_H
#define CORE_H

#include <Windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <xact3.h>
#include <strsafe.h>
#include "AudioState.h"
#include "InputHandler.h"

#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")

class Core
{
private:
	void createWindow(int nShowCmd);
	void initDirectX(); // initialize directx
	HRESULT PrepareXACT();
	void CleanupXACT();
	HRESULT FindMediaFileCch( WCHAR* strDestPath, int cchDest, LPCWSTR strFilename );
	bool DoesCommandLineContainAuditionSwitch();
protected:
	HINSTANCE hInstance;		// handle to application instance
	HWND hWnd;					// handle to the created window
	IDirect3D9* d3d;			// directx object

	// Is there any reason device should be protected???
public:
	IDirect3DDevice9* device;	// directx device

protected:
	ID3DXSprite* sprite;		// sprite used to draw to screen
	InputHandler* inputHandler;	// pointer to InputHandler
	AudioState audioState;		// pointer to AudioState
public:
	Core(HINSTANCE hInstance, int nShowCmd);	// constructor
	virtual ~Core();							// destructor
	virtual void initialise() = 0;				// declare starting values
	virtual void loadContent() = 0;				// load content
	virtual void update(float frameTime) = 0;	// update elements using game mechanics
	virtual void render() = 0;					// displays elements
	virtual void unloadContent() = 0;			// unload content
	LRESULT msgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); // win message handling
	const InputHandler* getInputHandler() const { return inputHandler; } // get InputHandler
	const AudioState getAudioState() const { return audioState; } // get AudioState
};

extern Core* game; // declare Game will exist to be initalised at runtime allowing global access

#endif // CORE_H